package com.itboye.sunsun.adapter;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.sunsun.application.App;
import com.itboye.sunsun.beans.LuntanTieziSouBeans.LunTanTieziSearBean;
import com.itboye.sunsunhome.R;

public class LunTanSouSuoSearTieziAdapter extends BaseAdapter{
	
	List<LunTanTieziSearBean> list;
	Context context;
	public  LunTanSouSuoSearTieziAdapter(List<LunTanTieziSearBean> list,Context context){
		this.list=list;
		this.context=context;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHouder houder;
		if(convertView==null){
			houder=new ViewHouder();
			convertView=LayoutInflater.from(App.ctx).inflate(R.layout.item_luntan_sear_sousuo, null);
			houder.title=(TextView) convertView.findViewById(R.id.sear_title);
			houder.name=(TextView) convertView.findViewById(R.id.sear_Time);
			
			houder.time=(TextView) convertView.findViewById(R.id.time);
			houder.conment=(TextView) convertView.findViewById(R.id.commont);
			convertView.setTag(houder);
		}else{
			houder=(ViewHouder) convertView.getTag();
		}
		
		houder.title.setText(list.get(position).getSubject());
		houder.name.setText(list.get(position).getName());
		
		houder.conment.setText(new SimpleDateFormat("yyyy-MM-dd HH:ss").format(Long
				.parseLong(list.get(position).getDateline())*1000));
		houder.time.setText(list.get(position).getReplies());
		return convertView;
	}
	class  ViewHouder{
		TextView title;
		TextView time;
		TextView conment;
		TextView pinlun;
		TextView name;
	}

}
